<template>
  <div id="sidebar-item" :class="{active:isActive}" @click="itemClick">
    <slot>默认文字</slot>
  </div>
</template>

<script>
  export default {
    name: "SideBarItem",
    props:{
      link:{
        type:String,
      },
    },
    data(){
      return {
        // isActive: false
      }
    },
    computed:{
      isActive(){
        return this.$route.path.indexOf(this.link) !== -1
      }
    },
    methods:{
      itemClick(){
        this.$router.push(this.link)
      },
    }
  }
</script>

<style scoped>
 #sidebar-item{
   height: 37px;
   line-height: 37px;
   color: #2a2727;
   cursor: pointer;
   margin-top: 2px;
   padding-left: 20px;
 }
 .active{
   font-size: 14px;
   font-weight: 550;
   border-right: 2px solid #bbbbf1;
   background-color: #e8f5fa;
 }

</style>
